<?php
/**
 * Created by PhpStorm.
 * User: freethy
 * Date: 2018/9/19
 * Time: 12:05
 */

namespace app\bus\controller;
use think\Db;
use think\Controller;

class User extends Controller
{
    public function lst()
    {
        $key = input('param.key');
        $key = urldecode($key);
        $arr = db("s_user")->where('name|number|account','like','%'.$key.'%')->limit(0,999999)->select();
        return json($arr);
    }
    public function lst_iqc()
    {
        $key = input('param.key');
        $key = urldecode($key);
        $arr = db("s_user")->where('name|number|account','like','%'.$key.'%')->where(['department_id'=>5])->limit(0,999999)->select();
        return json($arr);
    }

    public function pwd(){
        $user = get_user();
        $pwd = input('pwd');
        $pwd1 = input('pwd1');


        if($user['password'] != $pwd){
            return json(array("code" => 1, "text" => "原密码不正确"));
        }

        Db::table('s_user')->where(['id'=>$user['id']])->update(['password'=>$pwd1]);

        return json(array("code" => 0, "text" => "密码修改成功"));

    }
}



